package com.group01.community.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Locale;
import java.util.ResourceBundle;

@Slf4j
@Component
public class I18nUtils {
    private static Locale locale;
    private static ResourceBundle resourceBundle;
    private static final String BASENAME = "i18n/messages";

    public static String handleCN(String key) {
        locale = Locale.CHINA;
        resourceBundle = ResourceBundle.getBundle(BASENAME, locale);
        return resourceBundle.getString(key);
    }

    public static String handleUS(String key) {
        locale = Locale.US;
        resourceBundle = ResourceBundle.getBundle(BASENAME, locale);
        return resourceBundle.getString(key);
    }
}